this.BX=this.BX||{};(function(e){"use strict";var s=function(){function e(){var s=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,e);this.container=s.container;if(this.container&&typeof s.blurElement==="undefined"){s.blurElement=this.container.firstElementChild}this.blurElement=s.blurElement;this.direction=e.direction[s.direction]?s.direction:e.direction.vertical;s.sizes=s.sizes&&babelHelpers["typeof"](s.sizes)==="object"?s.sizes:{};this.sizes={circle:s.sizes.circle?s.sizes.circle:54,progress:s.sizes.progress?s.sizes.progress:4,margin:s.sizes.margin?s.sizes.margin:0};s.labels=s.labels&&babelHelpers["typeof"](s.labels)==="object"?s.labels:{};this.labels={loading:s.labels.loading?s.labels.loading:"",completed:s.labels.completed?s.labels.completed:"",canceled:s.labels.canceled?s.labels.canceled:"",cancelTitle:s.labels.cancelTitle?s.labels.cancelTitle:"",megabyte:s.labels.megabyte?s.labels.megabyte:"MB"};this.cancelCallback=typeof s.cancelCallback==="function"?s.cancelCallback:null;this.destroyCallback=typeof s.destroyCallback==="function"?s.destroyCallback:null;this.icon=e.icon[s.icon]?s.icon:!this.cancelCallback?e.icon.cloud:e.icon.cancel;this.inited=!!this.container;this.destroing=false}babelHelpers.createClass(e,[{key:"start",value:function s(){var i=this;if(!this.inited){return false}clearTimeout(this.timeoutSetIcon);clearTimeout(this.timeout);this.active=true;this.canceled=false;this.cancelCallbackDisabled=false;this.wrapper=document.createElement("div");this.wrapper.classList.add("ui-file-progressbar-loader-wrapper");this.wrapper.innerHTML='\n\t\t\t<div class="ui-file-progressbar-loader">\n\t\t\t\t<div class="ui-file-progressbar-icon"></div>\n\t\t\t\t<div class="ui-file-progressbar-progress ui-file-progressbar-rotating"></div>\n\t\t\t</div>\n\t\t\t<div class="ui-file-progressbar-label">'.concat(this.labels.loading,"</div>\n\t\t");this.processLoader=this.wrapper.getElementsByClassName("ui-file-progressbar-loader")[0];this.processLoaderIcon=this.wrapper.getElementsByClassName("ui-file-progressbar-icon")[0];this.processStatus=this.wrapper.getElementsByClassName("ui-file-progressbar-progress")[0];this.proccesLabel=this.wrapper.getElementsByClassName("ui-file-progressbar-label")[0];if(this.direction===e.direction.horizontal){this.wrapper.classList.add("ui-file-progressbar-loader-horizontal")}this.container.classList.add("ui-file-progressbar-container-relative");this.container.insertBefore(this.wrapper,this.container.firstChild);if(this.blurElement){this.blurElement.classList.add("ui-file-progressbar-item-blurred")}var t="width: ".concat(this.sizes.circle,"px; height: ").concat(this.sizes.circle,"px;");if(this.sizes.margin){t=t+"margin: ".concat(this.sizes.margin,"px;");this.proccesLabel.style="margin: ".concat(this.sizes.margin,"px;")}this.processLoader.style=t;if(this.cancelCallback){this.processLoader.addEventListener("click",(function(e){if(i.cancelCallbackDisabled){return false}i.setProgress(0);if(i.labels.canceled){i.setProgressTitle(i.labels.canceled)}i.canceled=e;i.active=false;clearTimeout(i.timeout);i.timeout=setTimeout((function(){return i.destroy()}),1e3);return true}));if(this.labels.cancelTitle){this.processLoader.title=this.labels.cancelTitle}}if(!this.labels.loading){this.setProgressTitleVisibility(false)}this.setIcon(this.icon,true);this.bar=new BX.ProgressBarJs.Circle(this.processStatus,{easing:"linear",strokeWidth:this.sizes.progress,color:"#ffffff",from:{color:"#ffffff"},to:{color:"#ffffff"},step:function s(t,r){if(r.value()==1){clearTimeout(i.timeout);i.timeout=setTimeout((function(){if(i.labels.completed){i.setProgressTitle(i.labels.completed)}i.setIcon(e.icon.done);clearTimeout(i.timeout);i.timeout=setTimeout((function(){return i.destroy()}),1e3)}),200)}}})}},{key:"setCancelDisable",value:function e(){var s=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;this.cancelCallbackDisabled=!!s;if(this.labels.cancelTitle){this.processLoader.title=this.cancelCallbackDisabled?"":this.labels.cancelTitle}}},{key:"setIcon",value:function s(i){var t=this;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;this.processLoaderIcon.style.transform="scale(0)";clearTimeout(this.timeoutSetIcon);this.timeoutSetIcon=setTimeout((function(){t.processLoaderIcon.classList.remove("ui-file-progressbar-cancel","ui-file-progressbar-done","ui-file-progressbar-cloud","ui-file-progressbar-error");if(i===e.icon.done){t.processLoaderIcon.classList.add("ui-file-progressbar-done");t.processLoaderIcon.style.transform="scale(1)"}else if(i===e.icon.cancel){t.processLoaderIcon.classList.add("ui-file-progressbar-cancel");t.processLoaderIcon.style.transform="scale(1)"}else if(i===e.icon.error){t.processLoaderIcon.classList.add("ui-file-progressbar-error");t.processLoaderIcon.style.transform="scale(1)"}else{t.processLoaderIcon.classList.add("ui-file-progressbar-cloud");t.processLoaderIcon.style.transform="scale(1)"}}),r?0:200);return true}},{key:"setProgress",value:function e(s){if(!this.active||this.canceled){return false}this.bar.animate(s/100,{duration:500})}},{key:"setProgressTitle",value:function e(s){if(!this.proccesLabel){return false}this.proccesLabel.innerHTML=s}},{key:"setProgressTitleVisibility",value:function s(i){if(!this.proccesLabel){return}if(i){if(this.direction===e.direction.horizontal){this.wrapper.classList.add("ui-file-progressbar-loader-horizontal")}this.proccesLabel.style.display="block"}else{if(this.direction===e.direction.horizontal){this.wrapper.classList.remove("ui-file-progressbar-loader-horizontal")}this.proccesLabel.style.display="none"}}},{key:"setByteSent",value:function e(s,i){if(this.canceled){return false}this.setProgressTitle((s/1024/1024).toFixed(2)+" "+this.labels.megabyte+" "+" / "+(i/1024/1024).toFixed(2)+" "+this.labels.megabyte)}},{key:"destroy",value:function e(){var s=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;clearTimeout(this.timeoutSetIcon);clearTimeout(this.timeout);if(this.destroing){return true}this.active=false;this.destroing=true;this.processLoader.style.transform="scale(0)";if(this.proccesLabel){this.proccesLabel.style.transform="scale(0)"}if(this.bar){this.bar.destroy()}if(this.blurElement){this.blurElement.classList.remove("ui-file-progressbar-item-blurred")}if(this.canceled&&!this.cancelCallbackDisabled){if(this.cancelCallback){this.cancelCallback(this.canceled)}this.canceled=false}if(i){this.timeout=setTimeout((function(){return s.destroyFinally()}),400)}else{this.destroyFinally()}}},{key:"destroyFinally",value:function e(){if(this.container){this.container.classList.remove("ui-file-progressbar-container-relative");this.container.removeChild(this.wrapper)}if(this.destroyCallback){this.destroyCallback()}}}]);return e}();s.direction={horizontal:"horizontal",vertical:"vertical"};s.icon={cloud:"cloud",cancel:"cancel",error:"error",done:"done"};e.Uploader=s})(this.BX.ProgressBarJs=this.BX.ProgressBarJs||{});
//# sourceMappingURL=uploader.bundle.map.js